package com.gomokult.servlet.gameplay;

import com.gomokult.exception.InvalidIDException;
import com.gomokult.service.impl.GameplayServiceImpl;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/servlet/CountGameScoreServlet")
public class CountGameScoreServlet extends HttpServlet {
    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        PrintWriter out = response.getWriter();
        int userID = Integer.parseInt(request.getParameter("userID"));
        int deltaScore = Integer.parseInt(request.getParameter("deltaScore"));
        try {
            out.print(GameplayServiceImpl.getSingleton().countScore(userID,deltaScore));
        } catch (InvalidIDException e) {
            out.print("#InvalidIDException");
        }
    }
}
